package net.qhzw.vip.qiyu.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.qhzw.vip.qiyu.entity.DtsUserBill;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.DtsUserBillService;
import net.qhzw.vip.qiyu.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("dts/userBill")
@Api(tags = "用户账单管理")
public class DtsUserBillController {

    @Autowired
    private DtsUserBillService dtsUserBillService;


    @ApiOperation(value = "查询用户账单列表")
    @GetMapping
    public JsonResult<Page<DtsUserBill>> findByPage(Page<DtsUserBill> page) {
        page.addOrder(OrderItem.desc("created"));
        Page<DtsUserBill> userBillPage = dtsUserBillService.page(page, new LambdaQueryWrapper<DtsUserBill>()
                .eq(DtsUserBill::getUserId, SecurityUtils.getUserId())
                .eq(DtsUserBill::getStatus, (byte) 1));
        return JsonResult.ok(userBillPage);
    }

}
